1. Field of the Invention
The invention relates to a memory, and more particularly, to a method for protecting data stored in a memory from unexpected events.
2. Description of the Related Art
In various modern electronic devices, such as digital cameras, laptop computers and handheld game consoles, a pluggable memory card plays an essential part as it not only flexibly augments storage spaces but also imparts high mobility to digital data. Apart from storing user data, a memory card is often utilized for storing software data or file systems of the memory. For example, a file system in a memory card may be in a file allocation table (FAT) format, such as the FAT32 format, or a New Technology File System (NTFS) format. Since a file system is utilized for recording corresponding physical locations of all sorts of files in a physical device, any damage to the file system may result in an external circuit from being unable to access the data stored in the memory card. Therefore, it is crucial to ensure intactness and correctness of data in a memory card under all conditions.
When a memory card is actually utilized, data stored in the memory card is often damages by unexpected events. For example, if an abnormal power failure or undervoltage occurs when an external circuit writes data into the memory, the data written into the memory and/or data previously stored in the memory can be damaged. Such damage may be a result of corresponding errors in a storage medium, inadequate error handling processes in the memory card, or inherent features of the internal storage medium (e.g., a flash memory) of the memory card.
When an error occurs in a logical or physical space of the storage medium in the memory card, data disorder of the data in the memory card will likely occur. Error handling is generally handled by firmware in the memory card. However, a flaw in a firmware program in the memory card may cause a disorder of the firmware, leading to data loss or even a permanent inaccessibility of the memory card in an abnormal power failure. Furthermore, inherent features of the storage medium in the memory card may also be factors that lead to errors in the memory card in an abnormal power failure. For example, in a multi-level cell (MLC) storage medium such as that employed in a flash memory, when an error occurs in data at one location, data damage owing to a corresponding paired location error is much more likely to occur.
In view of the above situations, the prior art has proposed remedial measures after an unexpected power failure has taken place; however, such errors are in fact better to be prevented in the first instance rather than fixed afterward.